<template>
  <div class="widget">
    <div class="header" v-if="header">
      <div class="title">
        <div class="icon">
          <img src="./images/s.png" />
        </div>
        <div class="text">{{ title }}</div>
        <div class="title-toolbar">
          <slot name="title-toolbar"></slot>
        </div>
      </div>
      <div class="toolbar">
        <slot name="toolbar"></slot>
      </div>
    </div>
    <div class="body">
      <slot></slot>
    </div>
  </div>
</template>

<script>
export default {
  name: "Widget",
  props: {
    title: String,
    header: {
      type: Boolean,
      default: true
    }
  },
};
</script>

<style scoped lang="scss">
.widget {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0px 4px 8px 0px rgba(0, 20, 45, 0.04);
  display: flex;
  flex-direction: column;
  overflow: hidden;

  .header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px;

    .title {
      display: flex;
      justify-content: center;
      align-items: center;

      .icon {
        margin-right: 5px;
      }

      .text {
        font-weight: bold;
        font-style: italic;
        font-size: 16px;
      }

      .title-toolbar {
        display: flex;
        justify-content: center;
        align-items: center;
        margin-left: 20px;
      }
    }

    .toolbar {
      display: flex;
    }
  }

  .body {
    flex: 1;
    display: flex;
  }
}
</style>
